Okay.
So today we're going to have a look at developer products.
Now last lesson um well last lesson I showed you how to create your own Game passes developer products
and badges, which we're going to be looking at in these few lectures here.
So if you haven't watched that already, I'd recommend you give that a watch so that you're aware how
to actually get visas.
You will need the ID of the Game Pass product or badge in order to code it.
Okay, but lesson previously, which was trying to mention there we looked at game passes.
Now think I did explain the difference between the two right at the start of the game pass lesson.
A bit more detail, but basically developer products can be purchased multiple times.
Game passes can only be be purchased purchased once.
The way of coding them is very similar.
So if you have already watched the Game Passes lecture, this will probably be quite an easy, easy
lecture to follow along with.
So we're going to start off with a local script inside starter player scripts, because we need to obviously
prompt the player with this time, not the game pass, but the revert to the developer product.
So we get marketplace service just as usual.
So local marketplace service is equal to game colon get service marketplace service.
And we're also going to get we also want to get the player as well.
So local player.
Is equal to game dot players, local player like that.
There we then we then want to get the product ID.
Now this will be the ID of your developer product.
Now I've got um product ID listed here in my notes.
So um
937521638
okay.
Cool.
Um, so and um, okay, so the to be honest, the developer products are probably easier, not easier,
but there's less code to write in order to do them than a game pass.
Because a game pass, you have to do a bit of checking as well to see if they have the game pass this
one.
You don't have to do that, you just have to prompt the purchase.
So all you'd have to say is marketplace service colon prompt purchase.
So not prompt purchase.
Um, prompt product purchase.
Make sure you use that specific one there with the player, um, with the product ID there as well.
Okay.
And that's it actually.
For this local script.
Now, obviously you can put this wherever you'd like.
I'm going to just very simply put, waiting for five seconds as last lesson.
I did it with a button, so there's no point me using that example again basically.
Um, so yeah, after five seconds is going to prompt us.
It's going to.
Okay.
So over then in a in server script over here we've done A or B prompting and GUI based stuff.
We obviously now want to return what happened if the purchase was successful or not.
Let's copy over to these variables here and obviously get rid of a player just to save us a little bit
of time.
Okay.
So, um, this one here, we're going to say we're going to make a function now.
Yeah.
There are a couple of ways you could do this.
Um, we're going to use the create a function in order to do this.
So we're going to make a local function.
And we're going to call this process receipt.
I believe I spelt it right.
No, I have not.
Receipt.
Cool.
With the receipt info this way.
This is where it differs a little bit from your game passes.
Okay, so first you want to fetch the player.
Now um, basically the receipt information.
We will assign it later on.
But this here is a parameter which stores multiple things.
One of the things it stores is the player's user ID who purchased this Game pass.
Sorry, this developer product.
Um, so we can get the player from their game pass.
So I can't speak today.
Get the player from their user ID, um, by using a handy function which you're going to use just here.
So local player available for the player is equal to game dot players colon get player by user ID.
And that's a quite useful function that you might want to use.
And the user id is just under receipt info dot player ID like that.
So you can use this parameter here to fetch the player.
Okay.
Um, now this is, um, now the receipt info.
But the good thing about this is that the receipt info, um, will this this will only work if it's
been successful or not.
So we also don't have to check if it's been, um, if it's all went through.
Okay.
Because it would have been successful no matter what.
Otherwise this function here, when we sign it later on, it wouldn't work basically.
So all we need to do is check if there is a player or if there is a player.
Because if there's no if there's no player, um, that means no one's purchased it successfully.
So the purchase was not successful.
So um, if not player, then we're going to use the return, um, method of doing this.
And basically we're going to return an enum value called enum dot product purchase decision dot.
And there are two methods here.
You can either say purchase granted or not processed yet.
So basically um, has it been successful?
Yes or no.
Basically those those two options mean.
So this one would be would mean no.
And then the other method of the other way to put this down put item else.
And then we just want to return um successful.
Dot purges, granted.
Like that.
Okay, cool.
And from there, all we will need to do under here is write down is obviously assign this function to
something.
So we're going to use marketplace service dot process receipt here.
Okay.
And we're going to make this um make this function equal to our function.
The process with seat function.
Okay.
So the time this when this function runs which, which is handled via the marketplace service, it will
then fire our function here to to work which will do all this code in here.
Now obviously if you are wanting to um, yeah.
If you're wanting to do any other other stuff in here, you would write it under here.
So this is where your extra code would go.
Oh.
Extra.
Can't write either.
Extra code would just go there.
So this could be just just let's just print a letter just to make sure that we know it works.
Okay.
But yeah, any code you want to if you want this to add, give them more cash, give them a speed boost
a temporary speed boost, any code like that which you would then go in there.
Now, I probably recommend not writing the code in just there, but having it fire a different function
or a different script, which then contains the code just to make it a bit cleaner and just have this
handle the product stuff.
But again, it's up to you how you'd like to do that.
Okay, let's play the game and try this out.
And so if I load in.
About five seconds time.
Should be prompted to purchase.
Yep.
It's the it's a similar one, but this one's slightly different because it's a product.
It's a it's a, um, developer product, not a game pass.
Okay.
And if we buy that, it then just, just prints a.
But you can just take that as an example of you can code whatever you'd like through there basically.
Um, so again I'm not going to show any examples of this because I think, um, well, the thing that
make makes most sense to show an example of would be um, giving a tool or something like that which
you looked at last lesson, um, or I don't think we, we didn't give a tool, but we added a part in,
um, but they would do it by, um, by clicking a button.
So kind of repeating myself a bit.
And they're both very similar.
It's just a slightly different method.
You need to use slight, slight different syntax.
You need to write down in order to code a product instead of a game pass.
Okay.
But um, this is it here.
Okay.
So now you're able to make these two.
That's really cool.
So you can add both of these into your game.
Just make sure that you are familiar with differences.
Keep those in mind and just double check that you're using the correct one um before you start coding
it.
Okay.
So now we're able to add these, um, game passes and products into your game.
Next, in the next lecture, we are going to have a look at badges and how to add badges into your game
as well.
So join me in the lecture next in the next lecture where we have a look at that.